import 'package:flutter/material.dart';
import 'package:getwidget/getwidget.dart';
import 'package:ichinesereader/controller/knowledgeword.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/widgets/dialogs/selectFolderDialog.dart';
import '../../constants.dart';

class BasicWordButtonBar extends GetView<KnowledgeWordsController> {
  BasicWordButtonBar({Key? key}) : super(key: key);
  // final KnowledgeWordsController _controller =
  //     Get.put(KnowledgeWordsController());

  @override
  Widget build(BuildContext context) {
    final isSmallScreen =
        MediaQuery.of(context).size.width < Constants.DefinedScreenSmallSize;
    return isSmallScreen
        ? Column(
            children: <Widget>[
              Expanded(
                child: Row(
                  children: [
                    InkWell(
                      child: Text(
                        "Go Back".tr,
                        style: TextStyle(
                            fontFamily: '',
                            color: Get.isDarkMode
                                ? Get.theme.primaryColorDark
                                : Colors.black87,
                            fontSize: 15.0),
                      ),
                      onTap: () {
                        Get.toNamed('/student/library');
                      },
                    ),
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(top: 12.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    Padding(
                      padding: const EdgeInsets.only(left: 6.0),
                      child: GFIconButton(
                        color: Theme.of(context).primaryColorDark,
                        onPressed: () {
                          //_controller.fetchKnowledgeFolderTree(false);
                          Future.delayed(Duration(milliseconds: 5600), () {
                            showGeneralDialog(
                                context: context,
                                transitionDuration: Duration(milliseconds: 400),
                                pageBuilder: (bc, ania, anis) {
                                  return SelectFolderDialog(
                                      title: 'Folder Or Word Card move',
                                      fromFolderId: controller.currdir[
                                              controller.currdir.length - 1]
                                          .toString(),
                                      from: 'basic100');
                                });
                          });
                        },
                        tooltip: 'Move to Folder'.tr,
                        icon: Icon(
                          // Icons.remove_circle_outline,
                          Icons.move_to_inbox,
                          color: Get.isDarkMode
                              ? Colors.black
                              : Theme.of(context).primaryColorLight,
                        ),
                        size: GFSize.SMALL,
                      ),
                    ),
                  ],
                ),
              )
            ],
          )
        : Row(
            children: <Widget>[
              Expanded(
                child: Row(
                  children: [
                    InkWell(
                      child: Text(
                        "Go Back".tr,
                        style: TextStyle(
                            fontFamily: '',
                            color: Get.isDarkMode
                                ? Get.theme.primaryColorDark
                                : Colors.black87,
                            fontSize: 15.0),
                      ),
                      onTap: () {
                        Get.toNamed('/student/library');
                      },
                    ),
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(left: 6.0),
                child: GFIconButton(
                  color: Theme.of(context).primaryColorDark,
                  onPressed: () {
                    showGeneralDialog(
                        context: context,
                        transitionDuration: Duration(milliseconds: 400),
                        pageBuilder: (bc, ania, anis) {
                          if (controller.mainMode.value) {
                            return SelectFolderDialog(
                                title: 'Folder Or Word Card move',
                                fromFolderId: controller
                                    .currdir[controller.currdir.length - 1]
                                    .toString(),
                                from: 'basic100');
                          } else {
                            return SelectFolderDialog(
                                title: 'Folder Or Word Card move',
                                fromFolderId:
                                    controller.recycleFolderId.toString(),
                                from: 'basic100');
                          }
                        });
                  },
                  tooltip: 'Move to Folder'.tr,
                  icon: Icon(
                    // Icons.remove_circle_outline,
                    Icons.move_to_inbox,
                    color: Get.isDarkMode
                        ? Colors.black
                        : Theme.of(context).primaryColorLight,
                  ),
                  size: GFSize.SMALL,
                ),
              )
            ],
          );
  }
}
